/**
*Copyright (C) 2011,China CQU EasyBoard Team.
*All rights reserved.
*
*File Name:msgheader.h
*File ID  :
*Summary  :in order to communicate with the server and other clients
*We need to make a protocol that we know with each other and know how
*to work.
*this file declares the protocol header,including the message type
*the reciver and the messge size etc.
*
*Version  :1.0.0
*Author   :YaoBoYuan
*Date     :2011-5-28
**/

#ifndef MSGHEADER_H
#define MSGHEADER_H

enum OPERATE  ///declare the operations of user commit to server
{
    LOGIN=0,
    LOGOUT,
    REGISTER,
    REQUEST,
    RESPOND,
    ADD,
    DELETE,
    UPDATE,
    BROWSE
};
enum TARGET   ///declare the operate target
{
    PASSWORD=0,
    INFO,
    CHAT,
    CALENDAR,
    TODOLIST,
    IDEABOX,
    YES,
    NO,
    NONE
};

class MSGHeader
{
public:

    OPERATE operation;  ///user operation
    TARGET target;      ///the target was operated
    short state;        ///show the current state of this package
    int len;            ///message body length,not contain the length of the header

    int option;         ///reserve field,for other use in the future
};

/**
 *the message body encaspulate convention:
 *<field1>
 *  <field1.1>content</field1.1>
 *  <field1.2>content</field1.2>
 *</field1>
 *<field2>content</field2>
 *   .
 *   .
 *   .
 *<field3>content</field3>
 *   .
 *   .
 *
 *those data should be holded in a QByte or a char array,like a DOM
 *also a XML file,so we can parser those data like XML
 *
 *the client send package:
 *when transfer data,we need to constuct a MSGHeader at first an fill
 *the fields,and then combine the true data Data togeter with Header
 *so,the package was transfered is package=MSGHeader+Data,and then
 *socket.send(package) to the server
 *
 *the client recieve package:
 *read the MSGHeader at first,MSGHeader = socket.read(n)'n is known'
 *then the MSGHeader.len contains the data length,so we can read the
 *true data,Data=socket.read(MSGHeader.len),then process the Data
 **/
#endif // MSGHEADER_H
